<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>仲裁列表</title>
<jsp:include page="../../import.jsp" flush="true" />
	<script src="<%=path %>/resource/lib/layui/layer/layer.js" charset="utf-8"></script>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
        	<div class="FXBR">
	            <div class="fieldBox">
	                <div class="label">项目id</div>
	                <div class="field">
	                    <input name="businessId" id="businessId" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	            </div>
				<div class="fieldBox">
					<div class="label">客户身份证号</div>
					<div class="field">
						<input name="certNo" id="certNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>
				</div>
				<div class="fieldBox">
					<div class="label">仲裁状态</div>
					<div class="field">
						<select name="status" id="status">
							<option value=" " selected>请选择</option>
							<option value="2">已仲裁</option>
							<option value="1">待上传仲裁合同</option>
							<option value="0">未仲裁</option>
						</select>
					</div>
				</div>
            </div>
            
            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	                <span id="searchBtn" onclick="searchBtn();" class="sq-button-round">查询</span>
	                <span id="clearBtn" onclick="clearBtn();" class="sq-button-round">清空</span>
	                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
        	</div>
        </form>
    </div>
</div>
<div id="demogrid" class="sq-grid"></div>

<script type="text/javascript">
	var grid = null;
	$(function () {
	    initForm();
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
		initEvent();
	});
	
	function initEvent(){
		 $("#redisBtn").click(function(event) {
			 var url = '<%=path%>/module/module/getRedisInfo.do';
			 AjaxUtils.ajaxGet(url, {}, redisCallback);
	    });
	}
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询按钮事件
	function searchBtn(){
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#demogrid").ligerGrid({
	    	url: '<%=path%>/arbitration/tcarbapply/initList.do',
	    	method : 'get',
	    	isSingleCheck: true,
	    	parms:getSearchParams(),
	        columns: [
	            { display: 'ID', name: 'id', width: 160 , align:'left', enabledSort:true
	            },
	            { display: '项目id', name: 'businessId', width: 120, enabledSort:true },
				{ display: '合同号', name: 'contractCode', width: 120, enabledSort:true },
	            { display: '客户名称', name: 'usrNm', width: 120, enabledSort:true },
				{ display: '身份证号', name: 'certNo', width: 120, enabledSort:true },
				{ display: '手机号码', name: 'phoneNo', width: 120, enabledSort:true },
				{ display: '机构名称', name: 'companyNm', width: 120, enabledSort:true },
				{ display: '逾期总金额', name: 'overdueAmount', width: 120, enabledSort:true },
				{ display: '本金', name: 'principal', width: 120, enabledSort:true },
				{ display: '还款日期', name: 'repaymentDate', width: 120, enabledSort:true },
				{ display: '逾期开始日期', name: 'overdueDate', width: 120, enabledSort:true },
				{ display: '逾期期数', name: 'overdueTimes', width: 120, enabledSort:true },
				{ display: '仲裁状态', name: 'status', width: 120, enabledSort:true ,render: function (rowdata, rowindex, value){
						if(rowdata.status==2){
							var h="仲裁成功";
							return h;
						}else if(rowdata.status==1){
							var h="待上传仲裁申请书";
							return h;
						}else{
							return "未仲裁"
						}

					}},

	            getGridOperColumnContent()
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true
	    });
	    grid = liger.get("demogrid");
	    grid.setHeight(100);
	}
	
	
  	//Grid操作列
    function getGridOperColumnContent(){

    	var data = {
                display: '操作',
                isSort: false,
                width: 300,
                render: function (rowdata, rowindex, value){
					var det = "<a class='sq-button-hasicon' href=\"javascript:detailPage('"+rowdata.id+"','mid_man_grid_id')\"><i class=\"sqBtnIco_4\"></i>查看详情</a>";
                	if(rowdata.status==0){
						var h="<a class='sq-button-hasicon' href=\"javascript:apply('"+rowdata.id+"','mid_man_grid_id')\"><i class=\"sqBtnIco_4\"></i>申请仲裁|</a>";
						return h+det;
					}else if(rowdata.status==1){
						var h="<a class='sq-button-hasicon' href=\"javascript:applyContract('"+rowdata.id+"','mid_man_grid_id')\"><i class=\"sqBtnIco_4\"></i>上传仲裁申请书|</a>";

						return h+det;
					}if(rowdata.status==2){

						return "仲裁申请提交成功|"+det;
					}

                }
            }
    	return data;
	}

	function detailPage(_id){
		layer.open({
			type: 2,
			title: '查看详情',
			shadeClose: true,
			shade: false,
			maxmin: true, //开启最大化最小化按钮
			area: ['90%', '600px'],
			content: '<%=path%>/arbitration/tcarbapply/detailPage.do?id='+_id
		});
	}
  	function apply(_id){
		layer.open({
			type: 2,
			title: '申请仲裁',
			shadeClose: true,
			shade: false,
			maxmin: true, //开启最大化最小化按钮
			area: ['90%', '600px'],
			content: '<%=path%>/arbitration/tcarbapply/applyPage.do?id='+_id
		});
  	}
	function applyContract(_id){
		$.post('<%=path%>/arbitration/tcarbapply/applyContract.do',{"applyId":_id},function (data) {
			if(data.success==1){
				layer.alert(data.info);
				grid.reload();
			}else{
				layer.alert(data.info);
			}
		},"json");
	}


	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
	
	//清空按钮事件
	function clearBtn(){
		 $("#resetBtn").click();  //重置 input-text
		 var form = new liger.get("searchBar");
		 form.setData({  //重置select等特殊表单
		     "empId":"",
			 "agtLine":"",
			 "agtNo":""
		  });
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
</script>

</body>
</html>